package com.wanxi.controller;

import com.wanxi.VO.DeviceClassVO;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.DeviceClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * 医疗设备分类
 * @Author : 林子淳
 * @create 2023/3/10 17:28
 */
@RestController
public class DeviceClassController {
    @Autowired
    private DeviceClassService deviceClassService;

    @PostMapping("/back/device_class/add")
    @CrossOrigin
    protected ResultDTO add(DeviceClassVO deviceClassVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceClassService.add(deviceClassVO);
        return resultDTO;
    }
    @PostMapping("/back/device_class/delete")
    @CrossOrigin
    protected ResultDTO delete(DeviceClassVO deviceClassVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceClassService.delete(deviceClassVO);
        return resultDTO;
    }
    @GetMapping("/back/device_class/findAll")
    @CrossOrigin
    protected ResultDTO findAll(DeviceClassVO deviceClassVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceClassService.findAll(deviceClassVO);
        return resultDTO;
    }
    @GetMapping("/back/device_class/findById")
    @CrossOrigin
    protected ResultDTO findById(DeviceClassVO deviceClassVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceClassService.findById(deviceClassVO);
        return resultDTO;
    }
    @PostMapping("/back/device_class/update")
    @CrossOrigin
    protected ResultDTO update(DeviceClassVO deviceClassVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = deviceClassService.update(deviceClassVO);
        return resultDTO;
    }

    }
